﻿using HandyControl.Controls;
using KinTN_WMS_CL.Extensions;
using KinTN_WMS_CL.Model;
using Prism.Common;
using Prism.Events;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace KinTN_WMS_CL.UserControlModels
{
    public class InViewModel : BindableBase
    {
        private readonly IEventAggregator _eventAggregator;
        private int _pageIndex;
        private int _totalCount;
        private int _pageSize = 10; // 默认每页显示 10 项

        public int PageIndex
        {
            get => _pageIndex;
            set => SetProperty(ref _pageIndex, value);
        }

        public int TotalCount
        {
            get => _totalCount;
            set => SetProperty(ref _totalCount, value);
        }

        public int PageSize
        {
            get => _pageSize;
            set => SetProperty(ref _pageSize, value);
        }

        private List<InDataModel> _data;

        public List<InDataModel> data
        {
            get => _data;
            set => SetProperty(ref _data, value);
        }
        public InViewModel(IEventAggregator eventAggregator)
        {

            _eventAggregator = eventAggregator;
            LoadData();
        }

        private void LoadData()
        {
            List<InDataModel> inDataModels = new List<InDataModel>();
            var homeItem = new InDataModel { Title = "首页", Icon = "\\Assets\\Images\\home.png", Name = "Home" };
            inDataModels.Add(homeItem);
            // 设置默认的内容
            data = inDataModels;

            // Create dynamic columns
            ListConversion listConversion = new ListConversion();
            listConversion.CreateDynamicColumns<InDataModel>();

            // Set up pagination

            PageIndex = 1;
        }
    }
}
